<?php
/**
 * Created by PhpStorm.
 * User: yuanbo
 * Date: 2018/8/22
 * Time: 下午9:04
 */

namespace app\admin\controller;


use think\Controller;

class MasterType extends  Controller
{
    //********大师类型列表*********
    public function typeList()
    {
        $typeList = db('mastertype')->select();
        $this->assign('typeList',$typeList);
        return $this->fetch('MasterType/typeList');
    }
    //*********修改大师类型********
    public function updateType()
    {
        $type_id  = input('type_id');
        $type = db('mastertype')->where('type_id',$type_id)->find();
        $this->assign('type',$type);
        return $this->fetch('MasterType/updateType');
    }
    //修改
    public function  update()
    {
        $type_id = input('type_id');
        $typename = input('typename');
        $data = ['typename'=>$typename];
        $rs = db('mastertype')->where('type_id',$type_id)->update($data);
        if($rs)
        {
            $this->success('修改成功');
        }
        else
        {
            $this->error('修改失败');
        }
    }
    //*******添加大师类型*********
    public function addType()
    {

        return $this->fetch('MasterType/addType');
    }
    //添加
    public function add()
    {
        //大师类型名称
        $type_name = input('type_name');
        //create_time
        $create_time = date('Y:m:d h:i:s');
        $data=['type_id'=>null,'type_name'=>$type_name,'create_time'=>$create_time];
        $rs = db('mastertype')->insert($data);
        if ($rs)
        {
            $this->success('添加成功');
        }
        else
        {
            $this->error("添加失败");
        }
    }
}